<?php
class Controller_Public extends Controller_Abstract
{
	function actionLogin()
	{
		$this->_view['title'] = "扫码枪登录";
		$username = isset($_REQUEST['UserID']) ? $_REQUEST['UserID'] : '';
		$password = isset($_REQUEST['UserPWD']) ? $_REQUEST['UserPWD'] : '';
		echo $password;exit;
		$user = User::find('name=? and password=?',trim($username),md5(trim($password)))->asArray()->getOne();
		if ($user['id'])
		{
			 session_start();
			 $_SESSION['UGType'] = 1;
			 $_SESSION['attrID'] = $user['name'];
			 echo 1;exit;
		}
		else
		{
			echo "not deny";exit;
		}
	}
	
	function actionProductInGZWarehouse()
	{
		$this->_view['title'] = '查询广州仓产品信息';
		$columns = array(
			'product_basic.number,product_basic.name',
			'product_warehouse.available_quantity,product_warehouse.actual_quantity,product_warehouse.shelf_position,product_warehouse.product_feature'
		);
		$product = Product_Warehouse::find('product_warehouse.warehouse_id=1 and product_basic.number=?', $_GET['number'])
			->joinLeft('product_basic', '', 'product_basic.id=product_warehouse.product_basic_id')
			->setColumns($columns)->asArray()->getOne();
		if ($product)
		{
			$ack = SUCCESS;
		}
		else
		{
			$ack = FAILURE;
		}
		echo json_encode(array('ack' => $ack, 'product' => $product));exit;
	}
}